Replace Chosen with native datalist for sponsor chapter filter - #2820
Open
mroderick wants to merge 4 commits into
Open
Replace Chosen with native datalist for sponsor chapter filter#2820mroderick wants to merge 4 commits into
mroderick wants to merge 4 commits into
Conversation
mroderick
marked this pull request as ready for review
August 29, 2026 13:05
mroderick
marked this pull request as draft
August 30, 2026 07:08
mroderick
force-pushed
the
feature/replace-chosen-sponsors-filter-clean
branch
5 times, most recently
from
August 30, 2026 10:27
9212787 to
ddafafe
Compare
Adds case-insensitive name-based chapter lookup as a fallback when filtering sponsors. Supports both chapter IDs (for programmatic use) and chapter names (for human-friendly filtering).
Reusable ViewComponent for single-chapter selection using native HTML datalist. Renders a text input with autocomplete=off backed by a datalist of chapter names. Sanitises the input name into a valid HTML id for the datalist element.
Replaces the chosen-select collection_select with the reusable ChapterPickerComponent. Also switches from simple_form_for to form_with for the filter form.
Replaces f.association :chapter select with ChapterPickerComponent. Adds resolve_chapter_name_to_id helper to the controller so the form can submit chapter names while the model still receives IDs.
mroderick
force-pushed
the
feature/replace-chosen-sponsors-filter-clean
branch
from
August 30, 2026 10:34
ddafafe to
3788be9
Compare
mroderick
marked this pull request as ready for review
August 30, 2026 10:37
| @@ -0,0 +1,15 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
| class ChapterPickerComponent < ViewComponent::Base | |||
Collaborator
There was a problem hiding this comment.
Minor: We should have an ApplicationComponent base class, I think, for an easier control point. It won't change anything right now, but it's neat to have prepared.
| require 'view_component/test_helpers' | ||
|
|
||
| RSpec.describe ChapterPickerComponent do | ||
| include ViewComponent::TestHelpers |
Collaborator
There was a problem hiding this comment.
Minor: we should make it so that each spec/components/ test get these by dint of having derived RSpec Metadata about their "type".
Or, check whether that's already true, and these helpers are already included.
olleolleolle
approved these changes
Aug 30, 2026
olleolleolle
left a comment
Collaborator
There was a problem hiding this comment.
I like a good datalist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces Chosen.js selects with a reusable
ChapterPickerComponentthat uses native HTMLdatalist+ text input withautocomplete="off".New: ChapterPickerComponent
A reusable ViewComponent that renders a text input backed by a
<datalist>with chapter names as values:The input shows the chapter name the user selects (not an ID), while the controller does a case-insensitive name lookup to resolve it. The
autocomplete="off"prevents browser autofill from fighting the datalist suggestions.Applied to
admin/sponsors/index) — replacescollection_selectwithchosen-selectclassadmin/workshops/_shared_form) — replacesf.association :chapterselectSponsorsSearch
Continues to do case-insensitive name lookup for chapter filtering (no change from the existing behaviour — the datalist now submits the name directly instead of an ID).
Why
Chosen is abandoned. This removes a JavaScript dependency and uses built-in browser autocomplete instead. The component is reusable — any form that needs single-chapter selection can use it.
Testing
bundle exec rspec spec/queries/sponsors_search_spec.rbbundle exec rspec spec/features/admin/filtering_sponsors_list_spec.rbbundle exec rspec spec/features/admin/workshops_spec.rbbundle exec rspec spec/components/chapter_picker_component_spec.rb